package net.cyndeline.components.agent

import net.cyndeline.entitySystem.Component
import net.cyndeline.ItemType
import net.cyndeline.entitySystem.EntityRef
import com.escalatesoft.subcut.inject.BindingModule
import net.cyndeline.Slots
import com.escalatesoft.subcut.inject.Injectable
import net.cyndeline.SlotStorage

/**
 * Lets an entity carry a number of spells.
 */
trait ObjectSlotsComponent extends Component {
  
  /**
   * @return Slot container.
   */
  def container: Slots
  
  def container_=(newContainer: Slots)
}

class ObjectSlots(implicit val bindingModule: BindingModule) extends ObjectSlotsComponent with Injectable {
  private var slots: Slots = injectOptional[Slots] getOrElse { new SlotStorage }
  
  override def container = slots
  override def container_=(newContainer: Slots) {
    slots = newContainer
  }
  
  def copy = {
    val cpy = new ObjectSlots()
    cpy.container = slots.copy
    cpy
  }
}